<?php echo $this->render('collection/site/_tab.phtml');?>
<form action="" method="post">
<?php if($this->items) { ?>
<div class="body">
	<table class="list">
		<tr>
			<th class="id">?</th>
			<th class="narrow">KEY</th>
			<th class="id"><?php echo $this->language('TITLE');?></th>
			<th><?php echo $this->language('LINK');?></th>
			<th class="id"></th>
		</tr>
		<?php foreach($this->items AS $key => $item) { ?>
		<tr id="id-<?php echo $key;?>">
			<td><?php
				if(in_array($key, $this->existing)) {
					echo '<em class="gray">EXISTING</em>';	
				} else {
					echo '<em class="red">NEW!</em>';	
				}
			?></td>
			<td><?php echo $this->form()->text('item[' . $key . '][key]', $key, array('size' => '8', 'maxlength' => '6'));?></td>
			<td><?php echo $this->form()->text('item[' . $key . '][title]', $item['title'], array('size' => '50', 'maxlength' => '250'));?></td>
			<td><?php echo $this->form()->text('item[' . $key . '][url]', $item['url'], array('size' => '50', 'maxlength' => '250'));?></td>
			<td><a href="#remove" onclick="if(confirm('<?php echo $this->language('Are you sure to Remove this item');?>?')){$('#id-<?php echo $key;?>').detach();}return false;"><?php echo $this->language('Remove');?>»</a></td>
		</tr>
		<?php } ?>
		<tr>
			<td colspan="5"><button type="submit" name="save" value="1"><?php echo $this->language('IMPORT');?></button></td>
		</tr>
	</table>
</div>
<?php } ?>
<?php if(!$this->items) { ?>
<?php echo $this->partial('collection/_inc/_ruleIndex.phtml', array('rule' => $this->row->getRule(), 'isNew' => $this->row->getId()));?>
<div class="body">
	<table class="form">
		<tr>
			<td width="180"></td>
			<td><button type="submit" name="collect" value="1"><?php echo $this->language('SAVE RULE & COLLECT');?></button></td>
		</tr>
	</table>
</div>
<?php } ?>
</form>
